home *** CD-ROM | disk | FTP | other *** search
- // Source Code generated by PatchMaker 1.0
- // a sick idea by Paul Baxter
-
- #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
- #error Sorry Can't do that
- #endif
-
- #include <MixedMode.h>
- #include <Appearance.h>
- #include <SpeechSynthesis.h>
-
- // enums for routinedescriptor
- enum {
- upp_StdTextProcInfo_0_0 = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1,kTwoByteCode)
- | STACK_ROUTINE_PARAMETER(2,kFourByteCode)
- | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
- | STACK_ROUTINE_PARAMETER(4,kFourByteCode),
- upp_StdTextProcInfo_1_0 = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1,kTwoByteCode)
- | STACK_ROUTINE_PARAMETER(2,kFourByteCode)
- | STACK_ROUTINE_PARAMETER(3,kFourByteCode)
- | STACK_ROUTINE_PARAMETER(4,kFourByteCode),
- uppPatcExtraInfo
- };
-
- // Function Prototypes
- extern pascal void my_StdText_0_0Patch(short param1, long param2, long param3, long param4);
- extern pascal void my_StdText_1_0Patch(short param1, long param2, long param3, long param4);
- pascal void my_StdTextPatch(short param1, long param2, long param3, long param4);
-
-
- // Globals to hold original routine descriptors
- RoutineDescriptorPtr gOriginal_StdText_0_0 = nil;
- RoutineDescriptorPtr gOriginal_StdText_1_0 = nil;
-
- #define EnterCodeResource()
- #define ExitCodeResource()
-
-
- // Tell MetroWerks the procInfo for main
- ProcInfoType __procinfo = kPascalStackBased;
- pascal void main(void)
- {
- RoutineDescriptorPtr originaldesc, newdesc, unImplimentedTrapAddr;
- UInt32 size;
- UInt16 index;
- THz theZone;
-
- // get globals
- EnterCodeResource();
- // detach ourselves
- DetachResource(Get1Resource('INIT', 0));
-
- // make sure we are in the system heap
- theZone = GetZone();
- SetZone(SystemZone());
-
- unImplimentedTrapAddr = NGetTrapAddress(_Unimplemented, (_Unimplemented & 0x0800) ? ToolTrap : OSTrap);
-
- originaldesc = NGetTrapAddress(_StdText, (_StdText & 0x0800) ? ToolTrap : OSTrap);
- if (originaldesc != unImplimentedTrapAddr) {
- if (originaldesc->goMixedModeTrap != _MixedModeMagic) {
- // Trap is 68K
- size = sizeof(RoutineDescriptor) + (sizeof(RoutineRecord) * 1);
- // allocate new descriptor
- newdesc = (RoutineDescriptorPtr) NewPtrSys(size);
- if (!newdesc) {
- Debugger();
- return;
- }
- // set fields of routine decscriptor
- newdesc->goMixedModeTrap = _MixedModeMagic;
- newdesc->version = 7;
- newdesc->routineDescriptorFlags = 0;
- newdesc->reserved1 = 0;
- newdesc->reserved2 = 0;
- newdesc->selectorInfo = 0;
- newdesc->routineCount = 1;
- index = 0;
- gOriginal_StdText_0_0 = originaldesc;
- newdesc->routineRecords[index].procInfo = upp_StdTextProcInfo_0_0;
- newdesc->routineRecords[index].reserved1 = 0;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- newdesc->routineRecords[index].routineFlags = 0;
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)my_StdText_0_0Patch;
- newdesc->routineRecords[index].reserved2 = 0;
- newdesc->routineRecords[index].selector = 0;
- index = 1;
- gOriginal_StdText_1_0 = originaldesc;
- newdesc->routineRecords[index].procInfo = upp_StdTextProcInfo_1_0;
- newdesc->routineRecords[index].reserved1 = 0;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- newdesc->routineRecords[index].routineFlags = 0;
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)my_StdText_1_0Patch;
- newdesc->routineRecords[index].reserved2 = 0;
- newdesc->routineRecords[index].selector = 0;
- }
- else {
- // Trap is PPC
- size = sizeof(RoutineDescriptor) + (sizeof(RoutineRecord) * originaldesc->routineCount);
- newdesc = (RoutineDescriptorPtr) NewPtrSys(size);
- if (!newdesc) {
- DebugStr("\pFailed to allocate RoutineDescriptor");
- return;
- }
- BlockMoveData(originaldesc, newdesc, size);
- for (index = 0; index <= newdesc->routineCount; index++) {
- if ((originaldesc->routineRecords[index].selector == 0) &&
- (originaldesc->routineRecords[index].ISA == 0) && (originaldesc->routineRecords[index].procInfo == upp_StdTextProcInfo_0_0)) {
- gOriginal_StdText_0_0= NewRoutineDescriptor(originaldesc->routineRecords[index].procDescriptor,
- upp_StdTextProcInfo_0_0, originaldesc->routineRecords[index].ISA);
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)my_StdText_0_0Patch;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- continue;
- }
- if ((originaldesc->routineRecords[index].selector == 0) &&
- (originaldesc->routineRecords[index].ISA == 1) && (originaldesc->routineRecords[index].procInfo == upp_StdTextProcInfo_1_0)) {
- gOriginal_StdText_1_0= NewRoutineDescriptor(originaldesc->routineRecords[index].procDescriptor,
- upp_StdTextProcInfo_1_0, originaldesc->routineRecords[index].ISA);
- newdesc->routineRecords[index].procDescriptor = (ProcPtr)my_StdText_1_0Patch;
- newdesc->routineRecords[index].ISA = GetCurrentArchitecture();
- continue;
- }
- }
- }
- NSetTrapAddress((UniversalProcPtr) newdesc, _StdText, (_StdText & 0x0800) ? ToolTrap : OSTrap);
- }
-
- // restore to original heap
- SetZone(theZone);
- // restore globals
- ExitCodeResource();
- }
-
-
- pascal void my_StdText_0_0Patch(short param1, long param2, long param3, long param4)
- {
- // Get globals
- EnterCodeResource();
-
- my_StdTextPatch( param1, param2, param3, param4);
-
- // Release globals
- ExitCodeResource();
- }
-
- pascal void my_StdText_1_0Patch(short param1, long param2, long param3, long param4)
- {
- // Get globals
- EnterCodeResource();
-
- my_StdTextPatch( param1, param2, param3, param4);
-
- // Release globals
- ExitCodeResource();
- }
-
- pascal void my_StdTextPatch(short param1, long param2, long param3, long param4)
- {
- SInt16 count, count1;
- Ptr theText = (Ptr)param2;
- char temp;
-
- // Get globals
- EnterCodeResource();
-
- for(count=0; count < param1; count++) {
- if (theText[count] >= 'a' && theText[count] <= 'z')
- theText[count] = (theText[count] - 'a') + 'A';
- }
-
- for(count=0; count < param1-1; count++) {
- for(count1=count+1; count1 < param1; count1++) {
- if (theText[count] <= theText[count1]) {
- temp = theText[count];
- theText[count] = theText[count1];
- theText[count1] = temp;
- }
- }
- }
-
- CALL_FOUR_PARAMETER_UPP( gOriginal_StdText_1_0, upp_StdTextProcInfo_1_0, param1, param2, param3, param4);
-
- // Release globals
- ExitCodeResource();
- }
-
-